home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / BHASH.CPP < prev    next >
C/C++ Source or Header  |  1994-06-25  |  16KB  |  371 lines

  1. // Copyright 1992 by Jon Dart.  All Rights Reserved
  2.  
  3. #include "bhash.h"
  4.  
  5.  
  6. static unsigned long hash_codes[64][16] =
  7.     {{0x08550102, 0x3289375b, 0x7146f3b3, 0x0a90b21b,
  8.     0xc3afd02a, 0x6d38f5d3, 0xcfecd6f3, 0x99a99a73,
  9.     0x671db88c, 0x7d79ab1f, 0x43de5890, 0x29b16c2e,
  10.     0x009fa589, 0x627644c9, 0x479a9460, 0x554bce2b}, 
  11.     {0x0d693d68, 0x6800fb7e, 0xf9411211, 0x3232675a,
  12.     0xe3c23f36, 0x8876bce7, 0x7b752109, 0xb31d4098,
  13.     0x0ae0e2a6, 0xc59e828d, 0x553c3740, 0x079d2290,
  14.     0xa1ce36f2, 0x928dbbb7, 0xd3de552b, 0xfbfdf49d}, 
  15.     {0xb74b82bc, 0x2c7ea349, 0x63c6628f, 0x562520a6,
  16.     0xb5a6a7eb, 0xffb8a9a7, 0xfb608f6b, 0x3c73f103,
  17.     0xb5a07e8b, 0x006eca95, 0x75fcb7d5, 0x90a4f05a,
  18.     0xe54f39b2, 0x149cf512, 0xecacbad8, 0x4fae497e}, 
  19.     {0xebfac15a, 0x6be9693e, 0x2525e256, 0xf39f2652,
  20.     0x3efa1944, 0xe0871537, 0xe49d43e7, 0xd28415a7,
  21.     0x8c9dbdd9, 0x5d10fbf9, 0x56ae18ba, 0x8140611d,
  22.     0x1500ff05, 0x386c8a3f, 0x6a342575, 0x2e747602}, 
  23.     {0x0ff56b1e, 0x92ab0562, 0x342d1513, 0x065a4432,
  24.     0x05df27be, 0xb9e9db3a, 0x4c9bdec8, 0x92a696f8,
  25.     0x35964fa9, 0x892b10fd, 0x30611ddb, 0x17677dee,
  26.     0xf34159a5, 0xc9429620, 0xa125788c, 0xf6e8a6dc}, 
  27.     {0x073c7262, 0x8eaab137, 0x052ffdf2, 0x0e8bc198,
  28.     0x0df4e254, 0x976653d3, 0xc84a82d8, 0x1ab1dfe8,
  29.     0xd6cb6798, 0xb1e78265, 0xb7a507a2, 0x1091ce60,
  30.     0xc7f299cf, 0x17e8b21b, 0x67ae1429, 0x85208140}, 
  31.     {0x3a4e4802, 0xcd4d27c2, 0x8ff8199d, 0x08eb695a,
  32.     0xde59dc81, 0x070658a7, 0x6d19cf64, 0x87fcd7ed,
  33.     0x15fbb7c0, 0x83ec4b73, 0x218897fc, 0xaab55f86,
  34.     0x5671913d, 0xeea4f611, 0x117fdbd7, 0x38b432e1}, 
  35.     {0x8d2cde5a, 0x3d7ca085, 0x47da6d41, 0x72b284ca,
  36.     0x7cac2640, 0x184f42d8, 0xd1f8e838, 0x775feaf8,
  37.     0x16656fbf, 0x2d60e3ed, 0x239c0f54, 0xa24bb7f4,
  38.     0xe4a0922c, 0x9b3dfc66, 0x75c82ea3, 0xecbd61f3}, 
  39.     {0x6654a546, 0x4ca0d685, 0x22a37a88, 0x4895dcbb,
  40.     0x6d0d530e, 0x554beb0a, 0x0a576e9e, 0x0632007e,
  41.     0x7fca41ae, 0x5bec4514, 0xf4ee3195, 0x364be1bd,
  42.     0x39dc6e57, 0xedfcdffe, 0xe838ef16, 0xffd0382a}, 
  43.     {0xaac68f20, 0xe59e0345, 0x95a3409e, 0x08cebb82,
  44.     0xb61c72e5, 0xce7fad61, 0xad248362, 0xd44c8272,
  45.     0x76695f2a, 0x3cb7eaac, 0x48103d2c, 0x222b6776,
  46.     0x980675fa, 0x30a8363d, 0x40fe803e, 0x4e0660b8}, 
  47.     {0xbe010dc4, 0x78dfdfc7, 0x97a9432f, 0xb014e9f1,
  48.     0xddf91641, 0x10f46180, 0xd0cfc7cf, 0xfd055b47,
  49.     0xa1017a4e, 0x7c68ccfa, 0x550ff602, 0xa5e45131,
  50.     0xc97d7bcf, 0x33881d05, 0xd3cac1a4, 0x37f70452}, 
  51.     {0x8805118f, 0xf24aa491, 0x9c068267, 0xbe9eb15c,
  52.     0xe843511e, 0x2731618b, 0x08485db2, 0x1e33f4f2,
  53.     0x24d2c4b6, 0x4a2763c0, 0xd07c9c85, 0x7cec2982,
  54.     0x0f21cf13, 0x42642cbb, 0x75cc1456, 0x98b9cc2a}, 
  55.     {0x6e520d5a, 0xc0470ca5, 0x9b8780f0, 0x2e23dc98,
  56.     0x5b18b3f8, 0xa23d8625, 0x6affe655, 0x562f36e5,
  57.     0xa69aee7c, 0x539caa43, 0xf066f29f, 0xe53cf97c,
  58.     0x31514380, 0x2c837d42, 0x7db35bde, 0xcee4e3f5}, 
  59.     {0x55e7f183, 0xcfbe5186, 0x087e3ef6, 0x7edbb4f6,
  60.     0x3d1a4ec8, 0x8ea12972, 0x8de28385, 0x41d08b14,
  61.     0x4b9b2a3d, 0xc4ed1b44, 0x685d39bd, 0x9d4b4ab3,
  62.     0x74ec2a53, 0x3dada9fd, 0xc0aef748, 0xb691f1e5}, 
  63.     {0xa24331e3, 0x8d142b39, 0xdab93e25, 0xad7e014b,
  64.     0x1367b50d, 0x78632514, 0x8562d68c, 0xfd6dddf3,
  65.     0xba932814, 0x4bc3ad09, 0x707032c8, 0xe110263b,
  66.     0x9e535547, 0x4429cbd0, 0x936eca1f, 0xae5520af}, 
  67.     {0x3b66bbd8, 0xe833d441, 0x858881a8, 0x37440eea,
  68.     0xe29ff8bf, 0x6e0bd231, 0xe86d0136, 0x29df9475,
  69.     0x17c11c9d, 0x1645dc54, 0xbd2f1f2e, 0x700316a7,
  70.     0xf4641498, 0x8dbf7a1e, 0xcb21356f, 0x94491986}, 
  71.     {0x86d0043c, 0x4e8207a0, 0x00ba882b, 0x19e2a4a7,
  72.     0x30e1a85c, 0xfea10b6a, 0xcc73a5cf, 0xe07b9a0d,
  73.     0x09e6b6f3, 0xd11ba06a, 0x83a8c1d9, 0x861c240a,
  74.     0x3c7f3a00, 0xe7b7d2cc, 0xbf771ac3, 0xc405071d}, 
  75.     {0x687ffb6a, 0xaae8fbdc, 0xbf9f56da, 0xd2920cd5,
  76.     0x03cdd8df, 0x35ac28e4, 0xc565e321, 0xc11b59b0,
  77.     0xb44027b1, 0xab6b730c, 0x796d5a35, 0xe1d1d9f8,
  78.     0xba8318bc, 0x9ed76b3b, 0x449fda27, 0x1d9f92a8}, 
  79.     {0x46f4133f, 0x6ccc6bf7, 0xb9076b5e, 0x5f0b1048,
  80.     0xdf8218c2, 0xa0330342, 0xebb05e7a, 0xe916bbd0,
  81.     0xbf9021f3, 0x51de4f80, 0xd38bac2e, 0xbf1b3e85,
  82.     0x36d17f86, 0x81675f51, 0xb04a5727, 0xfcafe5da}, 
  83.     {0x072e3d16, 0x81179174, 0x6240c9e6, 0x3d83f953,
  84.     0xcba07b03, 0x4ebff6a8, 0xd14635a3, 0xf6422961,
  85.     0x4f14d755, 0xf09aad88, 0x4894f72f, 0xdc70de43,
  86.     0xf348c29b, 0xdc2f4770, 0xd7a6f2cd, 0x3f4da8e7}, 
  87.     {0x0fadeaca, 0x56302558, 0xb11bf21b, 0x69b492ca,
  88.     0x4c47921b, 0xca56dab9, 0x8f940ce9, 0x05f88bd7,
  89.     0x098df8f2, 0x35488669, 0x0e95fe23, 0x78c9c247,
  90.     0xb946b1b6, 0x7e773d7c, 0x0f638da6, 0x42110583}, 
  91.     {0x446f0cb6, 0xd8fd6226, 0x1ae7e729, 0x63d32300,
  92.     0x67156e08, 0x24800899, 0xb88c0318, 0xb40f4d25,
  93.     0x1239b766, 0x500f54e4, 0xd81f0176, 0x4e9d7324,
  94.     0xcbac9e13, 0xb305dad8, 0x2fb189bc, 0xe411a5e0}, 
  95.     {0x0cf514b7, 0x76e700e1, 0x937329bc, 0x259976c9,
  96.     0xa22ba143, 0xe9455bea, 0x639bbd7a, 0x20de57be,
  97.     0x11d8c5cb, 0xec97113f, 0xde41c313, 0x9de3faed,
  98.     0xf0d95b6c, 0x4a223968, 0x8a3ec79c, 0x81e5b3b2}, 
  99.     {0x4b3ef428, 0x1cd63a0c, 0x920fbbff, 0x303dd478,
  100.     0x02283cc9, 0x252b2bd2, 0x24b359db, 0xe73d1396,
  101.     0x2baa54be, 0x3706363d, 0xd48b8567, 0x2213e236,
  102.     0x6dad39fe, 0x8f95f290, 0xf83baa51, 0xf8a5d72d}, 
  103.     {0x68c91ee4, 0x3830c8ac, 0x0d8b1d9d, 0x7f7708e0,
  104.     0x0e2ad115, 0x673b53f2, 0x13427b86, 0x26846a21,
  105.     0x056f155a, 0xdf05bc20, 0xf00c085c, 0x1a243313,
  106.     0x08870983, 0x51a41e32, 0xcd581366, 0xa6e93c05}, 
  107.     {0x49978347, 0xb8dde544, 0x783552c4, 0x907e5a56,
  108.     0xcad37123, 0xbcfd2b6f, 0xc4374348, 0x7a8ac653,
  109.     0xc4653a3b, 0x12bb1dad, 0xe7548e5e, 0x448f7817,
  110.     0x06461e38, 0xdd1958b3, 0xdec263e7, 0x69c7896c}, 
  111.     {0x5125942c, 0x094549d7, 0xc9deda1c, 0x610993ac,
  112.     0xbb41ae6e, 0xb1778ded, 0x4c03536b, 0x02a6109d,
  113.     0x104c747b, 0x7dcf5327, 0xf071d958, 0xdc49b955,
  114.     0x2d4b47d8, 0xff3ab9f6, 0x822b7c60, 0x9dd7ea17}, 
  115.     {0x687543ef, 0x18502fe9, 0x76d4b7d3, 0x7051ff37,
  116.     0xe81499f2, 0x5430d38e, 0x4195cdbb, 0x5ab1b2f5,
  117.     0x0b64f4b8, 0x4d69d751, 0xbff529b7, 0xa0cc8161,
  118.     0xc274d89f, 0x07cfdb5e, 0x8ec1bfdb, 0x21310839}, 
  119.     {0xf205026c, 0x54634f7d, 0x74e96b94, 0xb90c65c9,
  120.     0xd66bc42a, 0x3332d6f6, 0xb95b5284, 0xa10095cd,
  121.     0x5d6c6d0b, 0x3030a36f, 0x8aed4165, 0xce0dd84e,
  122.     0x8b21a247, 0xc01fd6ce, 0x58350ee5, 0x526d0c85}, 
  123.     {0xd6d5c1fd, 0xa968e416, 0x396af78a, 0xbb7210b7,
  124.     0x8be64011, 0x5b02f048, 0x49470391, 0x736d241a,
  125.     0x2ba40f11, 0x534d2f45, 0x06eb61ce, 0x238649b1,
  126.     0xcc32f60d, 0x7af245ac, 0xb4b4c988, 0x0da19f2e}, 
  127.     {0x7765f37e, 0x86c6a6b9, 0xba27dc61, 0x723bc8d3,
  128.     0x8ba5a024, 0x5aa9fa29, 0x07c7822e, 0xef4f464e,
  129.     0x1acb8de4, 0x64667616, 0x69fc4cdd, 0xdc2ddc9c,
  130.     0x4d06a5ab, 0x008f40d9, 0xf8f0d451, 0xb065ebea}, 
  131.     {0xbdb4894b, 0xd764d0e9, 0x6d701d44, 0x5d9fd871,
  132.     0xdd46f35e, 0x3caf4ebc, 0x87cbf026, 0xb17c675d,
  133.     0x50211722, 0x90a2f1a6, 0x69b143fe, 0xb87a1ba3,
  134.     0x517c015e, 0xa2be62ba, 0xfa188f4a, 0x19d19ae9}, 
  135.     {0x0d41f440, 0x0aaa1ba9, 0x47153ade, 0x79530966,
  136.     0x06e9cc39, 0x9019c4a3, 0xe1c2f0c4, 0xd84d6fba,
  137.     0x736560e4, 0x86ab9937, 0x3b19071d, 0xf36510d9,
  138.     0x9ff5dce1, 0x2cc6c431, 0x10dadc00, 0xa47dd5e2}, 
  139.     {0x4b0c26b7, 0x0d7ebf7d, 0xbe64355c, 0x4291a503,
  140.     0x0b2f3db2, 0x6371b803, 0xa89ba2d5, 0x0098c75a,
  141.     0xa7d798c7, 0x72a6e98e, 0x94c4daa5, 0x4b6444d2,
  142.     0x7d4f8670, 0xeb6fffa3, 0x0f671c7e, 0x307f4606}, 
  143.     {0xde94908c, 0x4d4a7868, 0xc72e9069, 0xb80f741d,
  144.     0x7236d645, 0x42bd0180, 0xf3c7a8a3, 0x47b75aaf,
  145.     0x923671e6, 0x013bd9ee, 0xaac17d81, 0xfe6fc1a2,
  146.     0xafead3c5, 0xae012df3, 0x4b6e3050, 0x1a6f1509}, 
  147.     {0xabd9251c, 0xb8f37eed, 0xd8c24c30, 0x5706c107,
  148.     0x409daaec, 0x3c86fa3c, 0x573524fa, 0x4b7f91ad,
  149.     0x5ac21ddd, 0x6293e31a, 0x33a0321d, 0xc8ff11db,
  150.     0x7ba6121d, 0xc142e884, 0x9c1e7b80, 0x4065ed1f}, 
  151.     {0x185b5540, 0xbae38a11, 0xe6f0eb5c, 0x1d2c5595,
  152.     0xfb854923, 0xdcd27ddb, 0xea54b626, 0x294955c8,
  153.     0xa43a4dc6, 0x42540057, 0x6470bb65, 0xe9093b93,
  154.     0xa7e21632, 0xf37a483a, 0x5628de9a, 0xfef8f8fc}, 
  155.     {0x09191156, 0x43ffd757, 0x67066e1a, 0x87ba791a,
  156.     0xa98dc6e6, 0x3229e181, 0x401481f2, 0x7feb10f3,
  157.     0x97dd333e, 0xcea6ab67, 0xf2c058c4, 0x1c07cc5b,
  158.     0x777e3041, 0x9071e878, 0x4fbab9aa, 0x3340ded2}, 
  159.     {0xe592cd37, 0xbeb01ec2, 0x50d45615, 0x9365f76a,
  160.     0xcfd4b2b0, 0xcb9202d1, 0x71e426a9, 0x6abfaba2,
  161.     0xd66c8060, 0xb430dc8e, 0x13a1cc25, 0xa0efca47,
  162.     0xb3d83105, 0x676fe122, 0xdc84f03c, 0x3cd5c956}, 
  163.     {0x91c77841, 0x1ade98d6, 0x16aba577, 0xbe6719d8,
  164.     0x72fa1d7d, 0xb39639ee, 0x10b4c718, 0x889a90c7,
  165.     0x882666c8, 0x221a0d8f, 0x7da157f4, 0x3239c1eb,
  166.     0x9fd16cba, 0xc43bcc9c, 0xd3b6e35a, 0xf6cd62ba}, 
  167.     {0x7335844e, 0xc5effe96, 0xb059deee, 0x0777a838,
  168.     0x181e9bc7, 0x793b5f7d, 0x34f30489, 0xf5d5a8d8,
  169.     0x53ca9691, 0xc40c38af, 0x64d0bc1d, 0x10dcba5b,
  170.     0x00c8b11a, 0x761bc3c9, 0x8afe7391, 0xbfc0d4b3}, 
  171.     {0x70dee4b9, 0xabcb8b86, 0x932d00a3, 0xe9cceddd,
  172.     0xc6e03c8c, 0x2a09cda0, 0x729100c8, 0x51465ec6,
  173.     0x5b974156, 0xc92dd5b0, 0x7fbe3c0b, 0xf6513e2a,
  174.     0x1d9d5262, 0xcad95f0c, 0xd58d03ec, 0x74c6c773}, 
  175.     {0xed40085f, 0x3adaf8a9, 0xb4f98e44, 0x631db29a,
  176.     0x02609246, 0x53085efb, 0xe0fd5c21, 0xb8479906,
  177.     0x474e1a33, 0xde24dfd6, 0x037a98a9, 0x238d576b,
  178.     0xbaaf214c, 0x8cbbba48, 0x0b1274f6, 0x747665af}, 
  179.     {0xd05be29b, 0x5f037e83, 0x880a88fb, 0xf3a341c4,
  180.     0xd23caef0, 0x03be6ab3, 0x13273a5f, 0xc7adc58b,
  181.     0x3b2d51c4, 0x3019cfe4, 0xa6941263, 0x55098db3,
  182.     0x1ede6f15, 0x0c886ee3, 0x00bd26bb, 0x9be8589a}, 
  183.     {0x7fafe348, 0x89aed717, 0x06307273, 0x9514622d,
  184.     0xba952207, 0xc635cc69, 0x207e3ace, 0x9dd0c9c8,
  185.     0xdef59924, 0x6db39f1f, 0x9c1b6c24, 0xc7bdec13,
  186.     0x0d880d78, 0x168993be, 0x0b3dfdc6, 0x46b4c9e7}, 
  187.     {0xdf3bfdc1, 0xa4c23ce9, 0xa2bc4cd9, 0xc8a8602a,
  188.     0xc109ff85, 0xa9f2dc42, 0x9ef27f39, 0xd68911b2,
  189.     0x54e422ef, 0xc21bc849, 0x9c9fe659, 0x3920fc21,
  190.     0xcd8f4db0, 0xf785c43d, 0x00c15923, 0x55f062ca}, 
  191.     {0x557ea2e3, 0x1fa666fc, 0x537b97d7, 0x8817048e,
  192.     0x6cb9d7e6, 0x3cfe74e1, 0xa1f3aaeb, 0x912e85bb,
  193.     0x44bb9e3f, 0xddf643a6, 0xdb2f43ec, 0xe829c6ef,
  194.     0x2450017a, 0x7ec31a44, 0x36f91b5e, 0x23344bf6}, 
  195.     {0xc878c209, 0xe64390d4, 0x8ebf5599, 0x549897ab,
  196.     0xc043bb26, 0x8ae0ee69, 0xbf6fdcb0, 0x6a988ed7,
  197.     0xd2b83fb1, 0xeb6e8af9, 0x0e5ac349, 0x9050d511,
  198.     0x57ac7a0f, 0xf70b2e37, 0x8215a681, 0x8e982f9f}, 
  199.     {0x9ca8d00e, 0x67007374, 0x475608cc, 0x29e3e456,
  200.     0x44c83dc0, 0x22a0237f, 0x0ed6b8d4, 0x801c177a,
  201.     0xa59bb660, 0x9b299787, 0x6c31295b, 0x708c319a,
  202.     0x2b028a2d, 0x31a41af9, 0x39c4da18, 0xf5b33879}, 
  203.     {0xb70ebd4e, 0x90c34860, 0xf690b199, 0x842e32e3,
  204.     0xfbe76eb0, 0x11c46c45, 0x23185d23, 0x6f948996,
  205.     0xe2a535e8, 0x194fe312, 0xa842b68f, 0x4655651f,
  206.     0xe731810e, 0x785678ed, 0x31351a30, 0x349d0db6}, 
  207.     {0x7e2afaa4, 0xcef6c99b, 0x8e3cd2ae, 0x62334d24,
  208.     0x6dbfe171, 0xe456a460, 0x13a56fe6, 0x5556cda1,
  209.     0x2d936d63, 0x128867de, 0xfa9d2bcf, 0x4da279b2,
  210.     0x509a326e, 0x9b6860f7, 0xc0194653, 0xa9edda0a}, 
  211.     {0xd8fb796c, 0x0f7e2fa9, 0x87ab6c34, 0x42277d6d,
  212.     0x9ef0a5ff, 0xaadb24f2, 0x756b0feb, 0xd03a4d8c,
  213.     0xaea6906e, 0xb5fa9daf, 0x16d2ca87, 0x45ecf7e6,
  214.     0xab1bef88, 0xe7a26d7a, 0xba9dc18d, 0x31bb48aa}, 
  215.     {0x2900ac81, 0xc0c4348d, 0xd4aa00d8, 0x21c38c93,
  216.     0x139a4dd5, 0xef5cc49f, 0x5ddadd7d, 0xfd98f3cc,
  217.     0x099d4f25, 0xaf4e7fc7, 0x32f154a2, 0x6a28e9d1,
  218.     0xbd148719, 0x284cb85a, 0x75736b69, 0x2b9f7f47}, 
  219.     {0x573a843f, 0xceb011cb, 0xec8b91c6, 0x7c3ec4e7,
  220.     0xd45bebef, 0xc160df8b, 0x61e3fc66, 0x7a472754,
  221.     0x64b8dc21, 0x2eab86eb, 0x04870b8d, 0x7bd0d904,
  222.     0xcc654e5a, 0xae2cdafb, 0xc8caa7f3, 0x72af2b17}, 
  223.     {0xc8267282, 0xa8a88066, 0xc51c9fa8, 0x5150ed3e,
  224.     0x64530fc7, 0xadee4f59, 0x97f30df3, 0x649ed398,
  225.     0x64b7e780, 0xdeb8ab5f, 0xc1a6b131, 0xb4dacf93,
  226.     0x9f6d1409, 0x458bed3f, 0x075055b6, 0x668373cb}, 
  227.     {0x60c668a4, 0x3a94bae2, 0xd3ad2caa, 0x1e3052eb,
  228.     0xc923cc5b, 0xc28f6c2d, 0x94fb31f0, 0x5975628b,
  229.     0x2ed8a4dd, 0xed9d69e4, 0x1edd86fc, 0xd3be5513,
  230.     0x790c2c60, 0x3a2f8a8b, 0x0736d8be, 0xe3330299}, 
  231.     {0x8798d781, 0xf2dc7942, 0x0c0dba78, 0xdf96bcc2,
  232.     0x8ae8b224, 0x8b4910aa, 0x6e6b0aa6, 0x7623bba0,
  233.     0x69dbc352, 0x0a02b7c0, 0x513b4dd9, 0x15737596,
  234.     0x21a0661b, 0x5c60cbc2, 0x1f2b1096, 0x47560133}, 
  235.     {0x209cb176, 0xbe67f60a, 0xe68c4a3e, 0x12b87516,
  236.     0xab44d41f, 0x18a494f3, 0xba31bae3, 0x58814acc,
  237.     0x3a00757c, 0x600d11b5, 0x104f4632, 0x3971b8b0,
  238.     0xdc0b1375, 0xf7e74a47, 0x245f604b, 0x700419cd}, 
  239.     {0x9252685c, 0x0b9deb3d, 0x57fa5ea6, 0xb55045bb,
  240.     0xb155c2c8, 0xf6a7d3ad, 0x8dbee2f2, 0x1ee5f781,
  241.     0x46066c76, 0x9f677007, 0x8f2a34f4, 0x7baf2874,
  242.     0x70aa072a, 0xda0a1ffe, 0x6b80a866, 0xbad4751a}, 
  243.     {0xc1b8ec90, 0xc765925f, 0xd3a5f6dc, 0x46937704,
  244.     0xa4ba8f19, 0x31db26fa, 0x7d00a39e, 0x65272bb3,
  245.     0xb32ddadb, 0xf3374c7a, 0x855a5889, 0x9aa64e77,
  246.     0x225e9176, 0x5190e54a, 0xcabf4af5, 0x04debd4e}, 
  247.     {0x154fb0ee, 0x5e27a374, 0x505e968c, 0xc13ad4c4,
  248.     0x0794cc8e, 0x5846657e, 0xa0689f32, 0x499fd1d5,
  249.     0x263471c8, 0x0a25a051, 0x27f073df, 0xd14b34cb,
  250.     0xb7868514, 0x2bc2b50f, 0x96cb2982, 0xabb91b1c}, 
  251.     {0x7116a5d0, 0xc0ca58fe, 0x44743de2, 0xa57ca550,
  252.     0xe0828a23, 0x7871ec5d, 0x8be4f87a, 0x6a2452dc,
  253.     0xc55a61d7, 0x1157e54f, 0x2a7ac75f, 0xe0186303,
  254.     0x7602323f, 0xb56728b1, 0xa6d4a419, 0x8d7d39b8}, 
  255.     {0x3c8d3d13, 0x58b56b01, 0xa4b66e88, 0xef11b47b,
  256.     0xb6a35b53, 0x1f61923a, 0x54e54ec2, 0xe30d973a,
  257.     0x36605c24, 0xb67615b8, 0xc50816f5, 0x0403e534,
  258.     0x23306ab3, 0xbbc65912, 0x4d899e45, 0x06c140d5}, 
  259.     {0x5bb26811, 0x15d11501, 0xe6742aaa, 0x1b304b97,
  260.     0x8c98501a, 0x59a0b239, 0x9059c5d5, 0x54320ae4,
  261.     0x9d85944b, 0x27a8a850, 0xac2aa00e, 0xf98443f2,
  262.     0x05f180ab, 0x8da6df97, 0x62197912, 0xf49dd9a8}};
  263.  
  264. unsigned long Board_Hash::HashCode( const Board &ABoard )
  265. {
  266.     unsigned long h = 0; // hashcode
  267.  
  268.     for (int i = 0; i<16; i++)
  269.     {
  270.         Square sq = ABoard.PiecePos(White,i);
  271.         if (!sq.IsInvalid())
  272.         {
  273.            Piece piece = ABoard[sq];
  274.            h ^= hash_codes[ sq ][ (int)piece ];
  275.         }
  276.         sq = ABoard.PiecePos(Black,i);
  277.         if (!sq.IsInvalid())
  278.         {
  279.            Piece piece = ABoard[sq];
  280.            h ^= hash_codes[ sq ][ (int)piece ];
  281.         }
  282.     }
  283.     if (ABoard.Side() == Black)
  284.        h |= 1;
  285.         else
  286.        h &= ~1;
  287.     return h;
  288. }
  289.     
  290. unsigned long Board_Hash::HashCode2( const Board & b)
  291. {
  292.     unsigned long h = 0;
  293.     for (int i = 0; i<16; i++)
  294.     {
  295.         Square sq = b.PiecePos(White,i);
  296.         if (!sq.IsInvalid())
  297.     {
  298.        Piece piece = b[sq];
  299.        h += (int)sq*(int)piece;
  300.     }
  301.         sq = b.PiecePos(Black,i);
  302.         if (!sq.IsInvalid())
  303.     {
  304.        Piece piece = b[sq];
  305.        h += 32*(int)sq*(int)piece;
  306.     }
  307.     }
  308.     return h;
  309. }
  310.  
  311. inline unsigned long Xor( unsigned long h, const Square &sq, const Piece &piece )
  312. {
  313. #ifdef RANGE_CHECK
  314.    assert(sq.OnBoard());
  315. #endif
  316.    return h ^ hash_codes[sq][(int)piece];
  317. }
  318.  
  319. void Board_Hash::UpdateHash( const Board &ABoard, 
  320.                const ExtendedMove &emove, 
  321.                const unsigned long OldHash, unsigned long &NewHash)
  322. {
  323.     unsigned long register h = OldHash;
  324.     if (!emove.IsNull())
  325.     {
  326.        Square kp;
  327.  
  328.        switch( emove.Special() )
  329.        {
  330.         case ExtendedMove::KCastle:
  331.            kp = ABoard.KingPos(ABoard.Side());
  332.            h = Xor(h, kp+3, Piece(Piece::Rook,ABoard.Side()));
  333.            h = Xor(h, kp, Piece(Piece::King,ABoard.Side()));
  334.            h = Xor(h, kp+1, Piece(Piece::Rook,ABoard.Side()));
  335.            h = Xor(h, kp+2, Piece(Piece::King,ABoard.Side()));
  336.            break;
  337.         case ExtendedMove::QCastle:
  338.            kp = ABoard.KingPos(ABoard.Side());
  339.            h = Xor(h, kp-4, Piece(Piece::Rook,ABoard.Side()));
  340.            h = Xor(h, kp, Piece(Piece::King,ABoard.Side()));
  341.            h = Xor(h, kp-1, Piece(Piece::Rook,ABoard.Side()));
  342.            h = Xor(h, kp-2, Piece(Piece::King,ABoard.Side()));
  343.            break;
  344.         case ExtendedMove::Normal:
  345.            h = Xor(h, emove.StartSquare(), emove.PieceMoved());
  346.            if (!emove.Capture().IsEmpty())
  347.               h = Xor(h, emove.DestSquare(), emove.Capture());
  348.            h = Xor(h, emove.DestSquare(), emove.PieceMoved());
  349.            break;
  350.         case ExtendedMove::EnPassant:
  351.         {    
  352.            Square dest = ABoard.EnPassantSq(ABoard.OppositeSide());
  353.            h = Xor(h, emove.StartSquare(), emove.PieceMoved());
  354.            h = Xor(h, dest, emove.Capture());
  355.            h = Xor(h, emove.DestSquare(), emove.PieceMoved());
  356.            break;
  357.         }
  358.         case ExtendedMove::Promotion:
  359.            h = Xor(h, emove.StartSquare(), Piece(Piece::Pawn,ABoard.Side()));
  360.            h = Xor(h, emove.DestSquare(), Piece(emove.PromoteTo(),ABoard.Side()));
  361.            break;
  362.        }
  363.     }
  364.     if (ABoard.Side() == White)
  365.        h |= 1;
  366.     else
  367.        h &= ~1;
  368.     NewHash = h;
  369. }
  370.  
  371.